home *** CD-ROM | disk | FTP | other *** search
- /* Init.c */
- /*
- * The init resource that installs the patch for the AutoCruise Mouse.
- * Be sure to set the attributes bits so this INIT resource is locked.
- * INIT 31 fails to do this for us.
- */
-
- #include "Cruise.h"
-
- main()
- {
-
- register crsrTaskVarsP varsAddress;
- register Ptr PatchPtr;
-
- asm /* Real men do it in assembly. */
- {
- clr.l DeskHook /* Why? Because DTS says so. */
-
- clr.l -(sp)
- move.l #'COOL',-(sp)
- move.w #128,-(sp)
- _GetResource
- move.l (a7),a1 /* leave result on stack for next trap */
- _DetachResource
- move.l (a1),PatchPtr /* put it somewhere */
-
- move.l #sizeof(crsrTaskVars),d0
- _NewPtr SYS+CLEAR
- move.l a0,varsAddress /* remember where it is for later */
- }
-
- /*
- * init variables. This prevents the cursor from jumping wildly
- * around the screen at bootup. It isn't strictly necessary, but it
- * doesn't hurt. Actually, I've now discovered that it is REALLY
- * important, and nothing will work worth two pickles if you
- * don't initialize everything.
- */
-
- varsAddress->OldCrsrTask=jCrsrTask;
- varsAddress->Prevh=(FixFlot)(Mouse.h)<<3;
- varsAddress->Prevv=(FixFlot)(Mouse.v)<<3;
- varsAddress->PrevInth=(FixFlot)Mouse.h;
- varsAddress->PrevIntv=(FixFlot)Mouse.v;
- varsAddress->LastTimeh=Ticks;
- varsAddress->LastTimev=Ticks;
-
- /*
- * Slightly specialized stuff. Basically, we install the patch
- * by modifing some zero page globals.
- */
- asm
- {
- move.l PatchPtr,a0 /* get saved pointer */
-
- move.l varsAddress,(a0) /* tell patch where to find its vars */
- addq.l #4,a0
- move.l a0,jCrsrTask /* tell system about patch */
- }
-
- }
-
- /*
- * Notice than an application or cdev can check to see if this patch
- * is installed by the following nifty trick:
- *
- * Pointer *aPtr;
- *
- * aPtr=jCrsrTask;
- * aPtr--; *** remember, '--' (of a pointer pointer) -> '-=4' ***
- * if (GetPointerSize(*aPtr)==sizeof(crsrTaskVars))
- * { It's installed }
- * else
- * { It's not installed }
- */